package com.sino.second.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;

public class FileManager {
	public static String fileUpload(File fromFile,String toFilePath,String toFileName) throws FileNotFoundException,IOException
	{
		InputStream is=new FileInputStream(fromFile);
		File destFile=new File(toFilePath,toFileName);
		OutputStream os=new FileOutputStream(destFile);
		byte[] buffer=new byte[400];
		int length=0;
		while((length=is.read(buffer))>0)
		{
			os.write(buffer,0,length);
		}
		is.close();
		os.close();
		return "fileUploadSuccess";
	}
	
	public static String getDateFileName()
	{
		SimpleDateFormat f = new SimpleDateFormat("yyyyMMddHHmmss");
		String time = f.format(new Date());
		return time;
	}
}
